package com.zatech.cgnci.project.controller.statement;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zatech.cgnci.project.dto.*;
import com.zatech.cgnci.project.service.CgnciBusinessInsuranceService;
import com.zatech.cgnci.project.service.CgnciReinsurancePremiumBillService;
import com.zatech.cgnci.project.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 临分保费账单信息 前端控制器
 * </p>
 *
 * @author Generator
 * @since 2025-01-13
 */
@RestController
@RequestMapping("/api/reinsurancePremiumBill")
@Api(produces = "application/json", tags = "账单管理api接口文档")
@RequiredArgsConstructor
public class CgnciReinsurancePremiumBillController {

    @Autowired
    private CgnciReinsurancePremiumBillService premiumBillService;

    @Autowired
    private CgnciBusinessInsuranceService insuranceService;

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询")
    public IPage<ReinsurancePremiumBillVO> pageHigherCode(@RequestBody ReinsurancePremiumBillDTO queryDTO) {
        return premiumBillService.pageQuery(queryDTO);
    }

    @GetMapping("/findById")
    @ApiOperation(value = "详情")
    public ReinsurancePremiumBillDetailsVO findCodeTypeByIdAndNumber(Long id) {
        return premiumBillService.getDetails(id);
    }

    @PostMapping("/addOrUp")
    @ApiOperation(value = "新增Or编辑")
    public void add(@RequestBody @Valid ReinsurancePremiumBillAddDTO addDTO) {
        premiumBillService.addContractInvoice(addDTO);
    }

    @PostMapping("/updateUpm")
    @ApiOperation(value = "更新UPM")
    public void updateUpm(@RequestBody ContractInvoiceUpmUpDTO updateDTO) {
        premiumBillService.updateUpm(updateDTO);
    }

    @GetMapping("/del")
    @ApiOperation(value = "删除")
    @Transactional(rollbackFor = Exception.class)
    public void del(Long id,String invoiceNumber) {
        premiumBillService.delete(id,invoiceNumber);
    }

    @GetMapping("/findByPolicyNumber")
    @ApiOperation(value = "根据保单号查询相关信息")
    public CgnciBillMainVO findCodeTypeByPolicyNumber(String policyNumber) {
        return premiumBillService.getPolicyInfo(policyNumber);
    }
}

